package com.kim.smartring.net;

import java.util.HashMap;
import java.util.Map;
import java.util.List;

/**
 * Title: 消息实体类 (类或者接口名称)
 * Description: XXXX (简单对此类或接口的名字进行描述)
 * Copyright: Copyright (c) 2012
 * Company:深圳彩讯科技有限公司
 *
 * @author duminghui
 * @version 1.0
 */
public abstract class AEntity {

	public String url;

	public String flag;
	/**
	 * 发送状态
	 */
	public String sentStatus = NetConstants.SENT_STATUS_WAIT;

	/**
	 * HTTP返回的头信码
	 */
	public int http_ResponseCode;
	/**
	 * 消息临听者
	 */
	private IReceiverListener receiverListener;

	/**
	 * 消息头
	 */
	public Map<String, String> httpHeaders;
	/**
	 * 服务器端返回的数据
	 */
	public String receiveData;
	
	/**
	 * 服务端返回的Cookies
	 */
	public Map<String, List<String>> receiveHeaders;

	public AEntity(IReceiverListener receiverListener) {
		this.receiverListener = receiverListener;
		init();
		httpHeaders = new HashMap<String, String>();
		receiveHeaders = new HashMap<String, List<String>>();
	}

	/**
	 * 初始化一些数据，如Flag、URL
	 * Name:    
	 * Description: 
	 * Author:        
	 * @return   
	 *
	 */
	protected abstract void init();

	/**
	 * 初始化Http头信息
	 * Name:    
	 * Description: 
	 * Author:        
	 * @return   
	 *
	 */
	protected abstract void initHttpHeader();

	/**
	 * 获取发送数据
	 * Name:    
	 * Description: 
	 * Author:    
	 * @return    
	 * @return   
	 *
	 */
	public abstract String getSendData();

	/**
	 * 解码网络返回的数据
	 * Name:    
	 * Description: 
	 * Author:        
	 * @return   
	 *
	 */
	public abstract void decodeReceiveData();

	/**
	 * 回传消息
	 * Name:    
	 * Description: 
	 * Author:        
	 * @return   
	 *
	 */
	public final void onReceive() {
		receiverListener.onReceive(this);
	}
}
